home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / ole2book.zip / CHAP06.ZIP / CHAP06 / COSCHMOO / DOCUMENT.CPP < prev    next >
C/C++ Source or Header  |  1993-04-15  |  18KB  |  815 lines

  1. /*
  2.  * DOCUMENT.CPP
  3.  * Component Schmoo Chapter 6
  4.  *
  5.  * Implementation of the CSchmooDoc derivation of CDocument as
  6.  * well as an implementation of CPolylineAdviseSink.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #include "coschmoo.h"
  19.  
  20.  
  21.  
  22. /*
  23.  * CSchmooDoc::CSchmooDoc
  24.  * CSchmooDoc::~CSchmooDoc
  25.  *
  26.  * Constructor Parameters:
  27.  *  hInst           HINSTANCE of the application.
  28.  */
  29.  
  30. CSchmooDoc::CSchmooDoc(HINSTANCE hInst)
  31.     : CDocument(hInst)
  32.     {
  33.     m_uPrevSize=SIZE_RESTORED;
  34.     m_pPL=NULL;
  35.     m_pPLAdv=NULL;
  36.     m_pIPersistStorage=NULL;
  37.  
  38.     //CHAPTER6MOD
  39.     m_pIAdviseSink=NULL;
  40.     m_dwConn=0;
  41.     //End CHAPTER6MOD
  42.     return;
  43.     }
  44.  
  45.  
  46. CSchmooDoc::~CSchmooDoc(void)
  47.     {
  48.     //CHAPTER6MOD
  49.     LPDATAOBJECT        pIDataObject;
  50.     HRESULT             hr;
  51.  
  52.     //Turn off the advise.
  53.     if (NULL!=m_pPL && 0!=m_dwConn)
  54.         {
  55.         hr=m_pPL->QueryInterface(IID_IDataObject, (LPVOID FAR *)&pIDataObject);
  56.  
  57.         if (SUCCEEDED(hr))
  58.             pIDataObject->DUnadvise(m_dwConn);
  59.         }
  60.  
  61.     if (NULL!=m_pIAdviseSink)
  62.         delete m_pIAdviseSink;
  63.     //End CHAPTER6MOD
  64.  
  65.     if (NULL!=m_pIPersistStorage)
  66.         m_pIPersistStorage->Release();
  67.  
  68.     if (NULL!=m_pPLAdv)
  69.         delete m_pPLAdv;
  70.  
  71.     if (NULL!=m_pPL)
  72.         m_pPL->Release();
  73.  
  74.     CoFreeUnusedLibraries();
  75.     return;
  76.     }
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. /*
  84.  * CSchmooDoc::FInit
  85.  *
  86.  * Purpose:
  87.  *  Initializes an already created document window.  The client actually
  88.  *  creates the window for us, then passes that here for further
  89.  *  initialization.
  90.  *
  91.  * Parameters:
  92.  *  pDI             LPDOCUMENTINIT containing initialization parameters.
  93.  *
  94.  * Return Value:
  95.  *  BOOL            TRUE if the function succeeded, FALSE otherwise.
  96.  */
  97.  
  98. BOOL CSchmooDoc::FInit(LPDOCUMENTINIT pDI)
  99.     {
  100.     RECT            rc;
  101.     HRESULT         hr;
  102.     //CHAPTER6MOD
  103.     FORMATETC       fe;
  104.     LPDATAOBJECT    pIDataObject;
  105.     //End CHAPTER6MOD
  106.  
  107.     //Change the stringtable range to our customization.
  108.     pDI->idsMin=IDS_DOCUMENTMIN;
  109.     pDI->idsMax=IDS_DOCUMENTMAX;
  110.  
  111.     //Do default initialization
  112.     if (!CDocument::FInit(pDI))
  113.         return FALSE;
  114.  
  115.     //Create the Polyline Object via COMPOBJ.DLL functions.
  116.     //CHAPTER6MOD
  117.     hr=CoCreateInstance(CLSID_Polyline6, NULL, CLSCTX_INPROC_SERVER
  118.         , IID_IPolyline6, (LPVOID FAR *)&m_pPL);
  119.     //End CHAPTER6MOD
  120.  
  121.     if (FAILED(hr))
  122.         return FALSE;
  123.  
  124.     //Initialize the contained Polyline which creates a window.
  125.     GetClientRect(m_hWnd, &rc);
  126.     InflateRect(&rc, -8, -8);
  127.  
  128.     if (FAILED(m_pPL->Init(m_hWnd, &rc, WS_CHILD | WS_VISIBLE, ID_POLYLINE)))
  129.         return FALSE;
  130.  
  131.  
  132.     //Set up an advise on the Polyline.
  133.     m_pPLAdv=new CPolylineAdviseSink((LPVOID)this, (LPUNKNOWN)this);
  134.  
  135.     if (NULL==m_pPLAdv)
  136.         return FALSE;
  137.  
  138.     m_pPL->SetAdvise(m_pPLAdv);
  139.  
  140.     //Get the IPersistStorage interface on the object for loads & saves.
  141.     hr=m_pPL->QueryInterface(IID_IPersistStorage, (LPVOID FAR *)&m_pIPersistStorage);
  142.  
  143.     if (FAILED(hr))
  144.         return FALSE;
  145.  
  146.     //CHAPTER6MOD
  147.     /*
  148.      * Create an IAdviseSink and send it to the Polyline's IDataObject
  149.      * with the clipboard format for the Polyline (as in IPOLY6.H).
  150.      */
  151.  
  152.     //This is a private macro.
  153.     SETDefFormatEtc(fe, m_cf, TYMED_HGLOBAL);
  154.  
  155.     m_pIAdviseSink=new CImpIAdviseSink((LPVOID)this, (LPUNKNOWN)this);
  156.  
  157.     if (NULL==m_pIAdviseSink)
  158.         return FALSE;
  159.  
  160.     //Set up an advise for the Polyline format
  161.     hr=m_pPL->QueryInterface(IID_IDataObject, (LPVOID FAR *)&pIDataObject);
  162.  
  163.     if (FAILED(hr))
  164.         return FALSE;
  165.  
  166.     pIDataObject->DAdvise(&fe, ADVF_NODATA, m_pIAdviseSink, &m_dwConn);
  167.     pIDataObject->Release();
  168.  
  169.     //End CHAPTER6MOD
  170.  
  171.     return TRUE;
  172.     }
  173.  
  174.  
  175.  
  176.  
  177. //CHAPTER6MOD
  178. //IUnknown interface for all the interfaces we implement in the document
  179.  
  180. /*
  181.  * CSchmooDoc::QueryInterface
  182.  * CSchmooDoc::AddRef
  183.  * CSchmooDoc::Release
  184.  *
  185.  * Purpose:
  186.  *  IUnknown members for the CSchmooDoc implementation.
  187.  */
  188.  
  189. STDMETHODIMP CSchmooDoc::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  190.     {
  191.     *ppv=NULL;
  192.  
  193.     //The document is the unknown
  194.     if (IsEqualIID(riid, IID_IUnknown))
  195.         *ppv=(LPVOID)this;
  196.  
  197.     //Return contained interfaces for others.
  198.     if (IsEqualIID(riid, IID_IPolylineAdviseSink6))
  199.         *ppv=(LPVOID)m_pPLAdv;
  200.  
  201.     if (IsEqualIID(riid, IID_IAdviseSink))
  202.         *ppv=(LPVOID)m_pIAdviseSink;
  203.  
  204.     /*
  205.      * If we actually assign an interface to ppv we need to AddRef it
  206.      * since we're returning a new pointer.
  207.      */
  208.     if (NULL!=*ppv)
  209.         {
  210.         ((LPUNKNOWN)*ppv)->AddRef();
  211.         return NOERROR;
  212.         }
  213.  
  214.     return ResultFromScode(S_FALSE);
  215.     }
  216.  
  217.  
  218. STDMETHODIMP_(ULONG) CSchmooDoc::AddRef(void)
  219.     {
  220.     return ++m_cRef;
  221.     }
  222.  
  223.  
  224. STDMETHODIMP_(ULONG) CSchmooDoc::Release(void)
  225.     {
  226.     /*
  227.      * Since CoSchmoo doesn't use documents like Component Objects, this
  228.      * doesn't do anything except provide a debugging point.
  229.      */
  230.     return --m_cRef;
  231.     }
  232.  
  233. //End CHAPTER6MOD
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240. /*
  241.  * CSchmooDoc::FMessageHook
  242.  *
  243.  * Purpose:
  244.  *  Processes WM_SIZE for the document so we can resize the Polyline.
  245.  *
  246.  * Parameters:
  247.  *  <WndProc Parameters>
  248.  *  pLRes           LRESULT FAR * in which to store the return value
  249.  *                  for the message.
  250.  *
  251.  * Return Value:
  252.  *  BOOL            TRUE to prevent further processing, FALSE otherwise.
  253.  */
  254.  
  255. BOOL CSchmooDoc::FMessageHook(HWND hWnd, UINT iMsg, WPARAM wParam
  256.     , LPARAM lParam, LRESULT FAR *pLRes)
  257.     {
  258.     UINT        dx, dy;
  259.     RECT        rc;
  260.  
  261.     if (WM_SIZE==iMsg)
  262.         {
  263.         //Don't effect the Polyline size to or from minimized state.
  264.         if (SIZE_MINIMIZED!=wParam && SIZE_MINIMIZED !=m_uPrevSize)
  265.             {
  266.             //When we change size, resize any Polyline we hold.
  267.             dx=LOWORD(lParam);
  268.             dy=HIWORD(lParam);
  269.  
  270.             /*
  271.              * If we are getting WM_SIZE in response to a Polyline
  272.              * notification, then don't resize the Polyline window again.
  273.              */
  274.             if (!m_fNoSize && NULL!=m_pPL)
  275.                 {
  276.                 //Resize the polyline to fit the new client
  277.                 SetRect(&rc, 8, 8, dx-8, dy-8);
  278.                 m_pPL->RectSet(&rc, FALSE);
  279.  
  280.                 /*
  281.                  * We consider sizing something that makes the file dirty,
  282.                  * but not until we've finished the create process, which
  283.                  * is why we set fNoDirty to FALSE in WM_CREATE since we
  284.                  * get a WM_SIZE on the first creation.
  285.                  */
  286.                 if (!m_fNoDirty)
  287.                     FDirtySet(TRUE);
  288.  
  289.                 SetRect(&rc, 0, 0, dx, dy);
  290.  
  291.                 if (NULL!=m_pAdv)
  292.                     m_pAdv->OnSizeChange((LPCDocument)this, &rc);
  293.  
  294.                 m_fNoDirty=FALSE;
  295.                 }
  296.             }
  297.  
  298.         m_uPrevSize=wParam;
  299.         }
  300.  
  301.     /*
  302.      * We return FALSE even on WM_SIZE so we can let the default procedure
  303.      * handle maximized MDI child windows appropriately.
  304.      */
  305.     return FALSE;
  306.     }
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315. /*
  316.  * CSchmooDoc::Clear
  317.  *
  318.  * Purpose:
  319.  *  Sets all contents in the document back to defaults with no filename.
  320.  *
  321.  * Paramters:
  322.  *  None
  323.  *
  324.  * Return Value:
  325.  *  None
  326.  */
  327.  
  328. void CSchmooDoc::Clear(void)
  329.     {
  330.     //Completely reset the polyline
  331.     m_pPL->New();
  332.  
  333.     CDocument::Clear();
  334.     return;
  335.     }
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342. /*
  343.  * CSchmooDoc::ULoad
  344.  *
  345.  * Purpose:
  346.  *  Loads a given document without any user interface overwriting the
  347.  *  previous contents of the Polyline window.  We do this by opening
  348.  *  the file and telling the Polyline to load itself from that file.
  349.  *
  350.  * Parameters:
  351.  *  fChangeFile     BOOL indicating if we're to update the window title
  352.  *                  and the filename from using this file.
  353.  *  pszFile         LPSTR to the filename to load, NULL for untitled.
  354.  *
  355.  * Return Value:
  356.  *  UINT            An error value from DOCERR_*
  357.  */
  358.  
  359. UINT CSchmooDoc::ULoad(BOOL fChangeFile, LPSTR pszFile)
  360.     {
  361.     HRESULT             hr;
  362.     //CHAPTER5MOD
  363.     LPSTORAGE           pIStorage;
  364.  
  365.     if (NULL==pszFile)
  366.         {
  367.         /*
  368.          * As a user of an IPersistStorage we have to provide all objects
  369.          * with an IStorage they can use for incremental access passing
  370.          * that storage to ::InitNew.  Here we create a temporary file
  371.          * that we don't bother holding on to.  If the object doesn't
  372.          * use it, then our ::Release destroys it immediately.
  373.          */
  374.  
  375.         hr=StgCreateDocfile(NULL, STGM_DIRECT | STGM_READWRITE | STGM_CREATE
  376.             | STGM_DELETEONRELEASE | STGM_SHARE_EXCLUSIVE, 0, &pIStorage);
  377.  
  378.         if (FAILED(hr))
  379.             return DOCERR_COULDNOTOPEN;
  380.  
  381.         m_pIPersistStorage->InitNew(pIStorage);
  382.         pIStorage->Release();
  383.  
  384.         Rename(NULL);
  385.         return DOCERR_NONE;
  386.         }
  387.  
  388.     /*
  389.      * Open a storage and pass it to the Polyline via IPersistStorage.
  390.      * We do not remain compatible with previous files saved with
  391.      * Component Schmoo.
  392.      */
  393.  
  394.     hr=StgOpenStorage(pszFile, NULL, STGM_DIRECT | STGM_READ
  395.         | STGM_SHARE_EXCLUSIVE, NULL, 0, &pIStorage);
  396.  
  397.     if (FAILED(hr))
  398.         return DOCERR_COULDNOTOPEN;
  399.  
  400.     hr=m_pIPersistStorage->Load(pIStorage);
  401.  
  402.     pIStorage->Release();
  403.     //End CHAPTER5MOD
  404.  
  405.     if (FAILED(hr))
  406.         return DOCERR_READFAILURE;
  407.  
  408.     if (fChangeFile)
  409.         Rename(pszFile);
  410.  
  411.     //Importing a file makes things dirty
  412.     FDirtySet(!fChangeFile);
  413.  
  414.     return DOCERR_NONE;
  415.     }
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423. /*
  424.  * CSchmooDoc::USave
  425.  *
  426.  * Purpose:
  427.  *  Writes the file to a known filename, requiring that the user has
  428.  *  previously used FileOpen or FileSaveAs in order to have a filename.
  429.  *
  430.  * Parameters:
  431.  *  uType           UINT indicating the type of file the user requested
  432.  *                  to save in the File Save As dialog.
  433.  *  pszFile         LPSTR under which to save.  If NULL, use the current name.
  434.  *
  435.  * Return Value:
  436.  *  UINT            An error value from DOCERR_*
  437.  */
  438.  
  439. UINT CSchmooDoc::USave(UINT uType, LPSTR pszFile)
  440.     {
  441.     BOOL                fRename=TRUE;
  442.     HRESULT             hr;
  443.     LPSTORAGE           pIStorage;
  444.  
  445.     if (NULL==pszFile)
  446.         {
  447.         fRename=FALSE;
  448.         pszFile=m_szFile;
  449.         }
  450.  
  451.     /*
  452.      * In Component Schmoo, we only deal with one version of data,
  453.      * so all the code in Chapter 2 Schmoo that dealt with 1.0 and
  454.      * 2.0 files has been removed.
  455.      */
  456.  
  457.     hr=StgCreateDocfile(pszFile, STGM_DIRECT | STGM_READWRITE
  458.         | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0, &pIStorage);
  459.  
  460.     if (FAILED(hr))
  461.         return DOCERR_COULDNOTOPEN;
  462.  
  463.     //Tell the object to save, and also tell it that we're done.
  464.     m_pIPersistStorage->Save(pIStorage, FALSE);
  465.     m_pIPersistStorage->SaveCompleted(pIStorage);
  466.  
  467.     pIStorage->Release();
  468.  
  469.     if (FAILED(hr))
  470.         return DOCERR_WRITEFAILURE;
  471.  
  472.     //Saving makes us clean
  473.     FDirtySet(FALSE);
  474.  
  475.     if (fRename)
  476.         Rename(pszFile);
  477.  
  478.     return DOCERR_NONE;
  479.     }
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486. /*
  487.  * CSchmooDoc::Undo
  488.  *
  489.  * Purpose:
  490.  *  Reverses a previous action.
  491.  *
  492.  * Parameters:
  493.  *  None
  494.  *
  495.  * Return Value:
  496.  *  None
  497.  */
  498.  
  499. void CSchmooDoc::Undo(void)
  500.     {
  501.     m_pPL->Undo();
  502.     return;
  503.     }
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511. /*
  512.  * CSchmooDoc::FClip
  513.  *
  514.  * Purpose:
  515.  *  Places a private format, a metafile, and a bitmap of the display
  516.  *  on the clipboard, optionally implementing Cut by deleting the
  517.  *  data in the current window after rendering.
  518.  *
  519.  * Parameters:
  520.  *  hWndFrame       HWND of the main window
  521.  *  fCut            BOOL indicating cut (TRUE) or copy (FALSE).
  522.  *
  523.  * Return Value:
  524.  *  BOOL            TRUE if successful, FALSE otherwise.
  525.  */
  526.  
  527. BOOL CSchmooDoc::FClip(HWND hWndFrame, BOOL fCut)
  528.     {
  529.     BOOL            fRet=TRUE;
  530.     HGLOBAL         hMem;
  531.     UINT            i;
  532.  
  533.     //This array is so we can loop over the formats we provide.
  534.     static UINT     rgcf[3]={0, CF_METAFILEPICT, CF_BITMAP};
  535.     const UINT      cFormats=3;
  536.  
  537.     if (!OpenClipboard(hWndFrame))
  538.         return FALSE;
  539.  
  540.     //Clean out whatever junk is in the clipboard.
  541.     EmptyClipboard();
  542.  
  543.     rgcf[0]=m_cf;
  544.  
  545.     for (i=0; i < cFormats; i++)
  546.         {
  547.         //Copy private data first.
  548.         hMem=RenderFormat(rgcf[i]);
  549.  
  550.         if (NULL!=hMem)
  551.             SetClipboardData(rgcf[i], hMem);
  552.         else
  553.             fRet &=FALSE;
  554.         }
  555.  
  556.     //Free clipboard ownership.
  557.     CloseClipboard();
  558.  
  559.     //Delete our current data if copying succeeded.
  560.     if (fRet && fCut)
  561.         {
  562.         m_pPL->New();
  563.         FDirtySet(TRUE);
  564.         }
  565.  
  566.     return fRet;
  567.     }
  568.  
  569.  
  570.  
  571.  
  572.  
  573. /*
  574.  * CSchmooDoc::RenderFormat
  575.  *
  576.  * Purpose:
  577.  *  Renders a specific clipboard format into global memory.  We have this
  578.  *  function split out because we'll eventually move to delayed rendering
  579.  *  and this will then be immediately callable from the frame.
  580.  *
  581.  * Parameters:
  582.  *  cf              UINT format to render.
  583.  *
  584.  * Return Value:
  585.  *  HGLOBAL         Global memory handle containing the data.
  586.  */
  587.  
  588. HGLOBAL CSchmooDoc::RenderFormat(UINT cf)
  589.     {
  590.     //CHAPTER6MOD
  591.     LPDATAOBJECT    pIDataObject;
  592.     FORMATETC       fe;
  593.     STGMEDIUM       stm;
  594.     HRESULT         hr;
  595.  
  596.     hr=m_pPL->QueryInterface(IID_IDataObject, (LPVOID FAR *)&pIDataObject);
  597.  
  598.     if (FAILED(hr))
  599.         return NULL;
  600.  
  601.     //Private macro--not OLE 2.0 defined API
  602.     SETFormatEtc(fe, cf, DVASPECT_CONTENT, NULL
  603.         , TYMED_HGLOBAL | TYMED_GDI | TYMED_MFPICT, 0);
  604.  
  605.     pIDataObject->GetData(&fe, &stm);
  606.     pIDataObject->Release();
  607.  
  608.     return stm.hGlobal;
  609.     //End CHAPTER6MOD
  610.     }
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618. /*
  619.  * CSchmooDoc::FQueryPaste
  620.  *
  621.  * Purpose:
  622.  *  Determines if we can paste data from the clipboard.
  623.  *
  624.  * Parameters:
  625.  *  None
  626.  *
  627.  * Return Value:
  628.  *  BOOL            TRUE if data is available, FALSE otherwise.
  629.  */
  630.  
  631. BOOL CSchmooDoc::FQueryPaste(void)
  632.     {
  633.     return IsClipboardFormatAvailable(m_cf);
  634.     }
  635.  
  636.  
  637.  
  638.  
  639.  
  640. /*
  641.  * CSchmooDoc::FPaste
  642.  *
  643.  * Purpose:
  644.  *  Retrieves the private data format from the clipboard and sets it
  645.  *  to the current figure in the editor window.
  646.  *
  647.  *  Note that if this function is called, then the clipboard format
  648.  *  is available because the Paste menu item is only enabled if the
  649.  *  format is present.
  650.  *
  651.  * Parameters:
  652.  *  hWndFrame       HWND of the main window
  653.  *
  654.  * Return Value:
  655.  *  BOOL            TRUE if successful, FALSE otherwise.
  656.  */
  657.  
  658. BOOL CSchmooDoc::FPaste(HWND hWndFrame)
  659.     {
  660.     HGLOBAL         hMem;
  661.     BOOL            fRet=FALSE;
  662.     //CHAPTER6MOD
  663.     LPDATAOBJECT    pIDataObject;
  664.     HRESULT         hr;
  665.     FORMATETC       fe;
  666.     STGMEDIUM       stm;
  667.     //End CHAPTER6MOD
  668.  
  669.     if (!OpenClipboard(hWndFrame))
  670.         return FALSE;
  671.  
  672.     hMem=GetClipboardData(m_cf);
  673.     CloseClipboard();
  674.  
  675.     if (NULL!=hMem)
  676.         {
  677.         //CHAPTER6MOD
  678.         hr=m_pPL->QueryInterface(IID_IDataObject, (LPVOID FAR *)&pIDataObject);
  679.  
  680.         if (FAILED(hr))
  681.             {
  682.             GlobalFree(hMem);
  683.             return FALSE;
  684.             }
  685.  
  686.         SETFormatEtc(fe, m_cf, DVASPECT_CONTENT, NULL, TYMED_HGLOBAL, 0);
  687.  
  688.         stm.tymed=TYMED_HGLOBAL;
  689.         stm.hGlobal=hMem;
  690.  
  691.         pIDataObject->SetData(&fe, &stm, TRUE);
  692.         pIDataObject->Release();
  693.  
  694.         FDirtySet(TRUE);
  695.         //End CHAPTER6MOD
  696.         }
  697.  
  698.     return TRUE;
  699.     }
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708. /*
  709.  * CSchmooDoc::ColorSet
  710.  *
  711.  * Purpose:
  712.  *  Changes a color used in our contained Polyline.
  713.  *
  714.  * Parameters:
  715.  *  iColor          UINT index of the color to change.
  716.  *  cr              COLORREF new color.
  717.  *
  718.  * Return Value:
  719.  *  COLORREF        Previous color for the given index.
  720.  */
  721.  
  722. COLORREF CSchmooDoc::ColorSet(UINT iColor, COLORREF cr)
  723.     {
  724.     COLORREF    crRet;
  725.  
  726.     m_pPL->ColorSet(iColor, cr, &crRet);
  727.     return crRet;
  728.     }
  729.  
  730.  
  731.  
  732.  
  733.  
  734. /*
  735.  * CSchmooDoc::ColorGet
  736.  *
  737.  * Purpose:
  738.  *  Retrieves a color currently in use in the Polyline.
  739.  *
  740.  * Parameters:
  741.  *  iColor          UINT index of the color to retrieve.
  742.  *
  743.  * Return Value:
  744.  *  COLORREF        Current color for the given index.
  745.  */
  746.  
  747. COLORREF CSchmooDoc::ColorGet(UINT iColor)
  748.     {
  749.     COLORREF    crRet;
  750.  
  751.     m_pPL->ColorGet(iColor, &crRet);
  752.     return crRet;
  753.     }
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760. /*
  761.  * CSchmooDoc::LineStyleSet
  762.  *
  763.  * Purpose:
  764.  *  Changes the line style currently used in the Polyline
  765.  *
  766.  * Parameters:
  767.  *  iStyle          UINT index of the new line style to use.
  768.  *
  769.  * Return Value:
  770.  *  UINT            Previous line style.
  771.  */
  772.  
  773.  
  774. UINT CSchmooDoc::LineStyleSet(UINT iStyle)
  775.     {
  776.     UINT    i;
  777.  
  778.     m_pPL->LineStyleSet(iStyle, &i);
  779.     return i;
  780.     }
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788. /*
  789.  * CSchmooDoc::LineStyleGet
  790.  *
  791.  * Purpose:
  792.  *  Retrieves the line style currently used in the Polyline
  793.  *
  794.  * Parameters:
  795.  *  None
  796.  *
  797.  * Return Value:
  798.  *  UINT            Current line style.
  799.  */
  800.  
  801.  
  802. UINT CSchmooDoc::LineStyleGet(void)
  803.     {
  804.     UINT    i;
  805.  
  806.     m_pPL->LineStyleGet(&i);
  807.     return i;
  808.     }
  809.  
  810.  
  811.  
  812. //CHAPTER6MOD
  813. //CPolylineAdviseSink moved to IADVSINK.CPP
  814. //End CHAPTER6MOD
  815.